from django import forms

class MarkItUpWidget(forms.Textarea):
    class Media:
        css = { 'all' : ( 'markitup/skins/simple/style.css',) }
        js = (
            '/ajax/markitup/jsi18n',
            'markitup/jquery.pack.js', 
            'markitup/jquery.markitup.js', 
        )

class TextileWidget(MarkItUpWidget):
    """
    MarkItUp widget for Textile markup language
    """
    class Media:
        css = { 'all' : ( 'markitup/sets/textile/style.css',) }
        js = (
            'markitup/sets/textile/set.js', 
            'markitup/sets/textile/run.js', 
        )

    def __init__(self, attrs={}):
        textileClass = ' textile_area'
        try:
            attrs['class'] += textileClass
        except KeyError:
            attrs['class'] = textileClass

        super(MarkItUpWidget, self).__init__(attrs=attrs)
